<?php

use App\Http\Controllers\IndustryController;
use App\Http\Controllers\KeywordSearchController;
use App\Http\Controllers\MerchantController;
use App\Http\Controllers\UserController;
use App\Http\Controllers\VersionController;
use App\Http\Middleware\EnsureTokenIsValid;
use Illuminate\Support\Facades\Route;

Route::middleware(['auth:sanctum', EnsureTokenIsValid::class])->group(function (){
    // 用户
    Route::post('users/register', [UserController::class, 'register'])->withoutMiddleware('auth:sanctum');
    Route::post('users/login', [UserController::class, 'login'])->withoutMiddleware('auth:sanctum');
    Route::get('users/info', [UserController::class, 'info']);

    // 商家
    Route::get('merchants/geoKeyword', [MerchantController::class, 'geoKeyword']);
    Route::get('merchants/geoNearBySearch', [MerchantController::class, 'geoNearBySearch']);
    Route::get('merchants/geoIndustry', [MerchantController::class, 'geoIndustry']);
    Route::get("merchants/geoGetLongitudeAndLatitude", [MerchantController::class, 'geoGetLongitudeAndLatitude']);
    Route::get("merchants/geoInputTips", [MerchantController::class, 'geoInputTips']);
    Route::get('merchants/geoLocationToAddress', [MerchantController::class, 'geoLocationToAddress']);
    Route::get('merchants/tencentKeyword', [MerchantController::class, 'tencentKeyword']);
    Route::get('merchants/tencentNearBySearch', [MerchantController::class, 'tencentNearBySearch']);
    Route::get('merchants/tencentIndustry', [MerchantController::class, 'tencentIndustry']);
    Route::get("merchants/tencentGetLongitudeAndLatitude", [MerchantController::class, 'tencentGetLongitudeAndLatitude']);
    Route::get('merchants/baiduKeyword', [MerchantController::class, 'baiduKeyword']);
    Route::get('merchants/baiduNearBySearch', [MerchantController::class, 'baiduNearBySearch']);
    Route::get('merchants/baiduIndustry', [MerchantController::class, 'baiduIndustry']);
    Route::get("merchants/baiduGetLongitudeAndLatitude", [MerchantController::class, 'baiduGetLongitudeAndLatitude']);
    Route::get('merchants/randomMerchant', [MerchantController::class, 'randomMerchant']);

    // 搜索记录
    Route::get('keywordSearches/export', [KeywordSearchController::class, 'export'])->withoutMiddleware('auth:sanctum');
    Route::apiResource('keywordSearches', KeywordSearchController::class);

    // 行业
    Route::apiResource('industries', IndustryController::class);

    // 版本
    Route::post('versions/getVersion', [VersionController::class, 'getVersion']);
});
